//
//  readutilUnitTest.h
//  pb_solvers_code
//
//  Created by Lisa Felberg on 3/10/16.
//  Copyright © 2016 Lisa Felberg. All rights reserved.
//

#ifndef readutilUnitTest_h
#define readutilUnitTest_h

#include "readutil.h"

/* Class to test opening PQR and XYZ files */
class ReadUtilUTest : public ::testing::Test
{
public :
  
protected :

  vector<double> sp_x = {2.965, 4.52, 7.092, 7.782, 7.614, 4.82, 4.093, 7.83, 
    6.265, 12.017, 9.993, 8.764, 12.731, 8.46, 4.095, 6.813, 8.422};
  vector<double> sp_z = {-1.084, -3.482, -6.049, 1.145, 4.029, 2.408, -0.923, 
    2.59, -6.542, 3.608, -7.069, 3.456, -4.511, -2.487, -3.01, -0.62, 1.101};
  vector<double> np_y = {-0.636, -0.442, -0.574, -0.594, -0.524, 0.526, -0.048,
   0.512, -0.779, -0.442, 0.201, -0.895, 0.184, -0.595, -0.171, -0.111, -0.75};
  vector<double> np_z = {-0.175, -0.581, -0.81, -0.453, -0.01, 0.656, -0.377,
   0.758, -0.608, 0.723, -0.842, 0.091, -0.82, -0.382, -0.296, -0.774, -0.22};
    
  vector<double> at_x = {48.33,47.142,33.522,41.035,41.864,31.784,30.898,
    33.893,49.156,48.227,39.79,35.538,34.849,43.227,51.263};
  vector<double> at_y = {40.393,25.566,25.331,26.912,35.127,33.217,38.365,
    35.594,40.035,27.504,25.017,34.25,44.167,48.997,35.216};
  vector<double> at_z = {9.798,-1.042,-0.851,4.988,8.574,8.786,4.028,17.666,
    1.901,-6.897,-13.315,-0.595,-2.71,5.886,-7.416};
  vector<double> at_r = {1.824,1.487,1.908,1.387,1.387,1.459,1.824,1.459,1.908,
    1.487,1.908,1.487,1.824,1.487,1.387};
  vector<double> at_c = {0.0966,0.0797,0.5973,0.1007,0.0922,0.1699,-0.4157,
    0.1417,-0.3192,0.0352,-0.0645,0.0791,-0.5163,-0.0122,0.0813};
  
  vector<double> cg_x = {41.47,30.915,44.892,30.335,41.072,27.716,40.051,
    29.456,37.415,23.556};
  vector<double> cg_y = {35.465,33.065,31.202,34.506,30.63,31.582,41.039,
    32.238,40.426,36.176};
  vector<double> cg_z = {0.47,3.732,-3.627,-1.291,8.115,3.988,8.699,15.186,
    13.57,1.911};
  vector<double> cg_r = {13.2578,6.3783,10.5985,4.666,8.7937,4.0027,5.0065,
    3.1349,1.6612,1.6612};
  
  vector<vector<double> > imat = {{0.155868,-0.219078,-0.201951,-0.0611878,-0.0580364,0.228865,0.0738525,0.0948085,0.0545233,-0.073026,0.132653,0.0792812,0.0255833,-0.0372471,-0.127082,-0.0384532,-0.0159833,-0.0146071,-0.134634,0.158562,0.213926,0.0267109,0.116472,-0.211907,-0.0206576,-0.176859,-0.0411747,-0.0407918,0.0511665,0.0267109,0.121033,0.0353766,-0.0206576,-0.166699,0.0565337,-0.145511,-0.0116073,-0.0223483,0.0349417,0.010613,0.0950381,0.00347438,-0.00144167,-0.0395287,-0.0205723,0.091546,-0.152498,-0.127144,-0.0123945,0.00694876,0.189942,0.0109237,0.0801675,0.0154919,0.029541,-0.0461439,-0.0123945,-0.10002,-0.00288334,0.0109237,0.16422,-0.0459855,0.103863,0.0379234,-0.01918,-0.106115,0.0339202,-0.0790573,0.0801675,-0.0459855,0.181627,-0.0165577,0.0218093,-0.0175285,-0.0247048,-0.0873065,-0.0411446,0.0154919,0.103863,-0.0165577,0.148532,},{0.271666,-0.123334,-0.300689,-0.253107,-0.109787,0.00752729,0.16165,0.0654185,0.245543,-0.0411113,0.227751,0.00260753,0.0559971,-0.0810147,-0.195727,-0.152401,0.0523365,-0.0142046,-0.200459,0.00521506,0.325671,0.120291,0.162139,0.00211085,-0.0200883,-0.256555,-0.239882,-0.168738,0.111994,0.120291,0.261574,0.157879,-0.0200883,-0.145919,0.169006,-0.218824,-0.0219575,-0.0486088,0.0486417,0.0473637,0.223773,0.0210822,0.0262632,-0.00723042,-0.0618038,0.00301092,-0.234872,0.00126651,-0.012053,0.0421644,0.308602,0.0995597,-0.0149708,0.0304231,0.0646599,-0.182881,-0.012053,-0.0875515,0.0525264,0.0995597,0.225388,-0.0801196,0.00390326,0.0261674,0.0628038,-0.153933,0.101404,-0.0144608,-0.0149708,-0.0801196,0.340587,0.0127177,0.0982172,-0.0170455,-0.143929,-0.131294,-0.123608,0.0304231,0.00390326,0.0127177,0.259972,},{0.203257,0.104915,0.277114,-0.116252,-0.248517,0.16056,0.0118676,0.116866,-0.0999503,0.0349716,0.103851,0.0556196,0.00411105,0.0563909,0.122182,-0.0208271,0.0585929,-0.0158561,0.184743,0.111239,0.31022,-0.0489655,-0.250232,0.15126,-0.0224239,0.253335,-0.0841257,-0.0775013,0.00822209,-0.0489655,0.195716,0.15768,-0.0224239,-0.0144659,0.138446,0.225926,-0.0497034,0.0338346,-0.0750695,0.0473039,0.171013,0.0242435,-2.73755e-05,-0.0214463,0.0412614,0.064224,0.146618,0.0907559,-0.0134544,0.048487,0.202325,-0.0142295,0.0792723,-0.0211767,0.00474703,-0.0249925,-0.0134544,-0.00867956,-5.4751e-05,-0.0142295,0.0815276,-0.0308889,0.0320298,0.0467463,0.0703115,0.152001,0.0830675,-0.0428926,0.0792723,-0.0308889,0.294109,0.0355679,-0.0399801,-0.0190273,-0.0504754,0.135556,0.0825229,-0.0211767,0.0320298,0.0355679,0.267348,},{0.645852,0.24903,0.248397,0.375959,0.136819,-0.0986649,-0.112241,0.0706835,-0.140294,0.08301,0.700579,-0.0341785,-0.0388813,0.186777,0.147671,0.22534,0.0193836,-0.0299831,0.165598,-0.068357,0.653114,-0.0687297,-0.158223,0.159206,-0.0424025,0.262327,0.284232,0.250639,-0.0777625,-0.0687297,0.583859,-0.236298,-0.0424025,0.104381,-0.323852,0.140294,0.0273638,0.112066,-0.0474669,-0.0708894,0.687117,-0.0302181,-0.050385,-0.0173614,0.0395489,-0.039466,0.177205,0.0955238,-0.0254415,-0.0604362,0.693304,-0.0499664,-0.0731383,-0.0153944,-0.0448962,0.270408,-0.0254415,0.0626286,-0.10077,-0.0499664,0.63458,0.0351104,0.0172518,0.0282734,0.0232604,0.157396,-0.194311,-0.0347228,-0.0731383,0.0351104,0.574467,-0.0350573,-0.0561176,-0.0359797,0.170539,0.0841761,0.0790979,-0.0153944,0.0172518,-0.0350573,0.639778,},{0.178581,0.321451,-0.12879,0.0924045,0.155385,-0.150981,0.188933,0.0844945,0.051981,0.10715,0.240735,-0.0523013,0.0654483,0.202325,-0.104882,0.129754,0.0107253,0.00956538,-0.0858602,-0.104603,0.188906,0.0254654,0.0329893,0.207672,0.0135275,-0.186375,0.0182035,0.061603,0.130897,0.0254654,0.106119,0.0707325,0.0135275,0.177336,-0.0786667,-0.00235433,0.0310769,0.121395,0.00989679,0.0212197,0.202704,-0.0330275,0.0493061,-0.0336678,-0.019037,-0.0603924,-0.125859,0.124603,0.0081165,-0.066055,0.228314,0.011355,-0.0945032,0.0504839,0.0755732,0.155704,0.0081165,0.106402,0.0986121,0.011355,0.200294,-0.0635209,-0.00180542,0.0337978,0.0128704,-0.111825,-0.0472,-0.0673357,-0.0945032,-0.0635209,0.160465,0.0106149,0.0207924,0.0114785,0.0109221,-0.0014126,-0.038074,0.0504839,-0.00180542,0.0106149,0.101165,},{0.160192,0.386323,-0.036661,0.0141069,0.400873,-0.0621893,0.039096,0.0608079,0.0189644,0.128774,0.320541,-0.021543,0.0135432,0.359176,-0.0385529,0.0342817,0.0367816,0.0106072,-0.0244407,-0.043086,0.109817,0.00929064,-0.00567393,0.216386,0.0150008,-0.0293013,-0.0197874,0.00940462,0.0270865,0.00929064,0.0502376,0.035866,0.0150008,0.112352,-0.0243423,-0.0182717,0.0801745,0.215506,-0.00170218,0.0107598,0.283892,-0.00638049,0.0237869,0.00455786,0.0002103,-0.0248757,-0.0462635,0.129832,0.0090005,-0.012761,0.268446,0.0158278,-0.0257796,-0.015297,0.0156384,0.041138,0.0090005,0.0674113,0.0475737,0.0158278,0.154261,-0.0277968,-0.0197881,0.0243232,0.0441379,-0.0175808,-0.0146054,0.00911573,-0.0257796,-0.0277968,0.056178,0.00566884,0.00758578,0.0127286,-0.0118725,-0.010963,0.000420599,-0.015297,-0.0197881,0.00566884,0.0382135,},{0.591693,-0.0299904,-0.396281,0.304307,0.109136,0.0858615,0.113346,-0.032009,0.118107,-0.00999679,0.635348,0.0297433,0.0392643,-0.049758,-0.253535,0.223398,0.0250303,0.00535691,-0.264187,0.0594866,0.554184,0.0578604,0.221332,0.0352677,0.00757582,-0.343272,0.137596,0.202871,0.0785287,0.0578604,0.585547,-0.12024,0.00757582,-0.0355287,-0.325601,-0.286356,0.0218273,-0.0298548,0.0663997,-0.0360721,0.646769,0.0185539,0.0345562,0.00996724,-0.0193023,0.0343446,-0.304242,0.0211606,0.00454549,0.0371077,0.581494,0.0649135,0.00499988,0.0464948,0.0453386,0.268078,0.00454549,-0.0213172,0.0691124,0.0649135,0.601211,-0.0178372,0.0499566,-0.0128036,0.0300364,-0.205963,-0.195361,0.0199345,0.00499988,-0.0178372,0.528145,-0.0278534,0.0472429,0.0064283,0.0825575,-0.171813,-0.0386047,0.0464948,0.0499566,-0.0278534,0.600843,},{0.154423,0.0500011,0.174991,-0.046977,0.146875,-0.0529579,-0.114618,0.140203,-0.103421,0.016667,0.213174,-0.0183451,-0.0397048,0.0859778,0.141377,-0.0310684,-0.0243248,-0.0529442,0.11666,-0.0366903,0.193735,-0.0506658,-0.0467782,-0.0359262,-0.0748744,0.174689,-0.106024,-0.031318,-0.0794097,-0.0506658,0.0563649,0.0244831,-0.0748744,0.0328747,-0.0321015,0.0825397,0.0293751,0.0515867,-0.0140335,0.00734492,0.19589,-0.0208901,-0.0371045,-0.0312111,0.0222879,-0.0211831,0.169653,-0.0215557,-0.0449246,-0.0417802,0.239251,-0.0480471,-0.0466898,-0.0573759,-0.0458472,-0.037282,-0.0449246,0.0197248,-0.074209,-0.0480471,0.112236,0.0059136,0.0205065,0.0560811,-0.0291898,0.104814,-0.0192609,-0.0624223,-0.0466898,0.0059136,0.126807,-0.0525128,-0.0413685,-0.063533,-0.0636146,0.0495238,0.0445757,-0.0573759,0.0205065,-0.0525128,0.0979463,},{0.40451,0.533628,0.0837997,-0.325935,0.113997,0.0359042,-0.0992577,-0.0994595,-0.0387929,0.177876,0.450109,0.0124376,-0.0343839,0.368169,0.0346775,-0.130915,0.0561867,0.0296422,0.0558665,0.0248752,0.332991,-0.0190045,-0.079603,0.380381,0.0419204,0.0671429,-0.26928,-0.21729,-0.0687678,-0.0190045,0.430441,0.316473,0.0419204,0.221461,0.303461,0.0793919,0.0227994,0.220901,-0.0238809,0.0949418,0.436236,-0.00231956,-0.00221809,0.0549033,0.0249681,0.0143617,0.041613,0.228229,0.0251522,-0.00463911,0.429819,0.00909847,0.033934,-0.0597943,-0.0397031,-0.157098,0.0251522,0.132877,-0.00443619,0.00909847,0.412923,0.0194382,-0.00272442,-0.0397838,0.067424,0.0402857,0.182076,0.109807,0.033934,0.0194382,0.363273,-0.00683352,-0.0155171,0.0355707,-0.161568,0.0476351,0.0499362,-0.0597943,-0.00272442,-0.00683352,0.380332,},{0.452483,-0.615434,0.173009,0.170838,0.129697,0.0615579,-0.0181859,0.0524159,0.172107,-0.205145,0.504362,0.0213243,-0.00629978,-0.376632,0.0443943,0.0433427,0.0210044,0.0215575,0.115339,0.0426485,0.452224,0.0843147,-0.211454,-0.345048,0.0304869,0.20665,0.216035,0.113892,-0.0125996,0.0843147,0.400867,-0.209659,0.0304869,-0.404457,-0.10204,0.115111,0.0259394,-0.225979,-0.0634363,-0.0628977,0.441551,-0.00825525,0.0112769,-0.0152799,-0.0613043,0.0246231,0.0532732,-0.207029,0.0182921,-0.0165105,0.520853,0.0404149,0.000430319,0.00931503,-0.00727436,0.0520112,0.0182921,-0.242674,0.0225538,0.0404149,0.485162,0.0333713,0.0565718,0.0209664,0.0252053,0.12399,-0.0612239,-0.0305598,0.000430319,0.0333713,0.410181,-0.00880113,0.0688426,0.025869,0.129621,0.0690666,-0.122609,0.00931503,0.0565718,-0.00880113,0.404679,},{0.475613,-0.536604,0.230078,-0.209942,-0.121924,-0.0324479,0.173716,0.0727323,0.146265,-0.178868,0.426844,-0.0112403,0.060177,-0.338135,0.0746027,-0.107156,-0.0211582,-0.047545,0.153386,-0.0224805,0.535627,0.071655,-0.254248,-0.351047,-0.0672387,0.184133,-0.152472,-0.139961,0.120354,0.071655,0.464364,0.164303,-0.0672387,-0.291203,0.200299,0.232761,-0.0243848,-0.202881,-0.0762745,0.049291,0.511174,-0.0225799,0.00774437,-0.00668133,-0.0380106,-0.0129791,0.0895233,-0.210628,-0.0403432,-0.0451597,0.459736,0.0573539,0.0105122,0.0708613,0.0694864,-0.128587,-0.0403432,-0.174722,0.0154887,0.0573539,0.362786,-0.0646541,-0.0185694,0.0290929,-0.0253898,0.11048,0.120179,-0.0133627,0.0105122,-0.0646541,0.494538,0.00318754,0.058506,-0.0570539,-0.0914833,0.139656,-0.0760211,0.0708613,-0.0185694,0.00318754,0.549819,},{0.335056,-0.172741,0.261635,0.320039,0.0984866,0.0476692,-0.0678147,-0.00650804,0.286642,-0.0575802,0.37445,0.0165131,-0.0234917,-0.166442,0.125808,0.248039,-0.000922922,0.0151893,0.174424,0.0330262,0.31217,0.140425,-0.218153,-0.0714298,0.0214809,0.199434,0.261494,0.213359,-0.0469834,0.140425,0.318547,-0.103783,0.0214809,-0.0688194,-0.216393,0.245667,0.0196973,-0.0998649,-0.0654459,-0.0311348,0.388066,0.0378242,-0.0184048,-0.00615946,-0.0631729,0.0190677,0.15097,-0.0428579,0.0128885,0.0756485,0.317172,0.130881,-0.0169136,-0.00628143,-0.0271259,0.297647,0.0128885,-0.0412916,-0.0368097,0.130881,0.347916,0.0340616,0.0249519,-0.00260321,-0.00110751,0.11966,-0.129836,-0.0123189,-0.0169136,0.0340616,0.355875,0.00121108,0.114657,0.0182271,0.156896,0.1474,-0.126346,-0.00628143,0.0249519,0.00121108,0.266249,},{0.15447,0.121128,-0.168117,0.0190872,-0.062532,-0.114139,0.0822845,0.169312,0.111385,0.040376,0.129457,-0.0395389,0.0285042,0.093061,-0.0869564,0.0574378,0.00339006,-0.0158622,-0.112078,-0.0790777,0.249927,0.0545674,0.129583,0.067621,-0.0224325,-0.23333,-0.0613563,0.0127248,0.0570084,0.0545674,0.084036,0.0676733,-0.0224325,0.0580325,-0.0597032,-0.0483512,-0.0125064,0.0558366,0.0388748,0.020302,0.126143,-0.0210265,0.0356666,-0.0641495,-0.0412309,-0.0456556,-0.104348,0.0405726,-0.0134595,-0.0420531,0.186009,0.0236158,-0.0670358,-0.00576298,0.0329138,0.0689254,-0.0134595,0.0348195,0.0713332,0.0236158,0.119034,-0.0438263,-0.00899007,0.0677249,0.00406808,-0.139998,-0.0358219,-0.128299,-0.0670358,-0.0438263,0.209405,0.0409763,0.0445541,-0.0190346,-0.0368138,-0.0290107,-0.0824619,-0.00576298,-0.00899007,0.0409763,0.131789,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0.0421626,-0.0786909,-0.046226,-0.0459108,0.0245041,0.0793435,0.0788211,0.000459394,0.0654783,-0.0262303,0.0519643,0.0274854,0.0273044,-0.0244847,-0.0502946,-0.0499735,-0.000250795,-0.0370607,-0.0308174,0.0549708,0.0374856,0.0320777,-0.0100695,-0.0619388,-0.0524118,-0.00793309,-0.0511233,-0.0306072,0.0546089,0.0320777,0.0370355,-0.0100386,-0.0524118,-0.0612295,0.00725514,-0.0508617,0.00490081,-0.0146908,-0.00302084,-0.00301158,0.0199464,0.0107471,0.0106943,-9.11264e-06,0.000939645,0.0317374,-0.0603535,-0.0371633,-0.0314471,0.0214942,0.0655079,0.0549972,0.0081274,0.048109,0.0315285,-0.0599682,-0.0314471,-0.0367377,0.0213886,0.0549972,0.0647874,-0.00751635,0.0478813,0.000183758,-0.000300954,-0.00475985,0.00435309,-1.82253e-05,0.0081274,-0.00751635,0.0136551,0.00024822,0.0261913,-0.0444729,-0.030674,-0.030517,0.00187929,0.048109,0.0478813,0.00024822,0.0469225,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0.149275,-0.322142,-0.14039,-0.0108526,0.245922,0.250425,0.0225979,0.0535253,0.00339696,-0.107381,0.247644,0.0867496,0.00782813,-0.231378,-0.167611,-0.0172989,-0.0222708,-0.000935805,-0.0935935,0.173499,0.126309,0.00166417,-0.0563266,-0.20789,-0.00132343,-0.0880986,-0.00415909,-0.00723509,0.0156563,0.00166417,0.0738654,-0.0118748,-0.00132343,-0.144899,0.00576163,-0.079953,0.0491844,-0.138827,-0.016898,-0.00356243,0.194701,0.0543128,0.00939212,-0.0131478,-0.00176058,0.10017,-0.201133,-0.124734,-0.000794057,0.108626,0.223198,-0.000101405,0.0766962,0.00312917,0.00903914,-0.0207586,-0.000794057,-0.0869395,0.0187842,-0.000101405,0.178732,-0.00765326,0.0834284,0.0214101,-0.026725,-0.0528592,0.00345698,-0.0262956,0.0766962,-0.00765326,0.0743947,0.000232272,0.00135879,-0.00112297,-0.00249545,-0.0479718,-0.00352116,0.00312917,0.0834284,0.000232272,0.0753414,}};
  
  vector<double> scl = {0.21053961,0.21876572, 0.20721523,0.25887287, 0.28581228, 0.22452233, 0.24682216, 0.24901018, 0.23949801, 0.25229589,0.22783195,0.26022692,0.1781166,0.67249496,0.60197448,0.68540096,0.60197448};
  vector<vector<double> > spolHre = {{-0.0569086405,0.0260712491,0.0257008958,0.005235481,-0.0173118192,-0.00856180981,},{-0.00611941969,0.00594485643,0.00287648502,-0.00651224062,-0.00319916935,-0.00294197438,},{0.0437630592,0.00897099853,0.021365849,-0.010795667,0.00812032763,0.00741899161,},{0.0262325702,0.00376868189,-0.00193586639,0.00588471844,-0.00442058501,0.00352281361,},{0.00552877158,0.00343211886,-0.000668543102,0.000670821156,-0.000545964471,-1.62130723e-05,},{0.00389986602,0.00296673714,0.00310364176,0.00140067842,0.00376161814,0.000243639236,},{-0.00775466188,0.00707921297,-0.000750470591,-0.00428955526,-0.00312968678,0.00332338452,},{0.01385662,0.00744574551,0.00599528001,-0.000340534389,0.00271589914,0.00308182702,},{0.00993887881,-0.000675493325,0.00665943185,-0.00595874867,0.00299361641,0.00289549569,},{-0.0149772211,0.00424168113,0.00967218429,0.00315292941,-0.0136369135,-0.0047657203,},{-0.000461199252,0.000431210264,0.00511957525,0.00443801572,-0.00189542418,0.000902068878,},{-0.000249898416,0.0054983672,0.00164742839,-0.00280048924,0.00095732225,0.000312721953,},{-0.011538862,0.00264896378,0.0110225964,0.00602643143,-0.00111149331,-0.00692120288,},{0,0,0,0,0,0,},{-0.00583782653,0.00375597016,0.00211968652,-0.000909173754,-0.00226138201,-8.03077652e-05,},{0,0,0,0,0,0,},{-0.0179288621,0.0124900461,0.00582895032,-0.00504592791,-0.00605247196,-0.0012599674,}};
  vector<vector<double> > spolHim = {{0.0,0.0,0.00964459858,0.0,-0.00757944296,-0.00659596823,},{0.0,0.0,-0.00165224429,0.0,-0.00163459396,0.000665664871,},{0.0,0.0,-0.00799556909,0.0,0.000818580529,-0.00554613199,},{0.0,0.0,-0.00312593082,0.0,-0.00542440823,-0.00804289631,},{0.0,0.0,0.0019811018,0.0,0.00217794045,-3.33506992e-05,},{0.0,0.0,0.00181958663,0.0,0.00245912205,-0.000807222416,},{0.0,0.0,0.00539860387,0.0,-0.00631708316,-0.00593820284,},{0.0,0.0,-0.00378680756,0.0,-0.00194501527,-0.00423593348,},{0.0,0.0,-0.00170593345,0.0,0.00213817344,-0.00135504186,},{0.0,0.0,0.00323553694,0.0,-0.00385667828,-0.00131770137,},{0.0,0.0,0.00110581322,0.0,-0.00128095382,-0.00123417624,},{0.0,0.0,0.000763496041,0.0,0.000432218781,-0.000172166312,},{0.0,0.0,0.00490396708,0.0,0.000829682693,-0.00291276804,},{0.0,0.0,0,0.0,0,0,},{0.0,0.0,0.00202452493,0.0,-0.00215584911,-0.00171813831,},{0.0,0.0,0,0.0,0,0,},{0.0,0.0,0.00159123612,0.0,-0.0018105596,-0.0010116607,}};
  vector<vector<double> > spolFre = {{0.0441857541,-0.0199085448,-0.020878782,-0.00457017258,0.0140744712,0.00798887252,},{0.00366588127,-0.00262835472,-0.000999072376,-4.18060593e-05,0.00127608791,-0.000170762753,},{-0.0718193097,-0.016840448,-0.0381514486,0.0181623461,-0.0143706679,-0.016769726,},{-0.172777903,-0.0563312691,-0.0144647656,-0.0217831081,0.00293096895,-0.00165514847,},{-0.00141046846,-0.000301886988,0.000938720222,0.000600481838,0.000501150525,-0.000572681613,},{-0.00068833022,-0.000602562117,1.47414978e-05,-0.00044595265,2.75120392e-05,5.50230226e-05,},{0.0164583225,-0.012244879,0.00201544505,0.0113395068,0.0119294672,0.00012380472,},{-0.0050765153,-0.00192262841,-0.00257725484,0.000262185395,-0.00115490362,-0.0012712798,},{-0.0489305991,-0.022097321,-0.0102562302,-0.00189178433,-0.00703342908,0.00445122855,},{0.050022961,-0.0348875929,-0.00472978697,0.0172016093,0.00639062461,-0.000670909907,},{-0.0198434657,0.0194169949,-0.00538786785,-0.0126046399,0.00572279708,-0.00518359431,},{0.0145589195,-0.005693701,0.00423613145,-0.000209829042,-0.0016949563,-0.000572450921,},{0.00904922284,0.00294379441,-0.00456172621,-0.00137281415,-0.00289705488,0.00335369683,},{0,0,0,0,0,0,},{0.000685685842,-0.000405964774,-0.000248722109,4.16540907e-05,0.000244034346,-1.93668292e-05,},{0,0,0,0,0,0,},{0.0283733277,-0.0208733848,-0.00907562668,0.0102630238,0.010123643,0.00241235825,}};
  vector<vector<double> > spolFim = {{0.0,0.0,-0.00663657798,0.0,0.00491956015,0.00500337345,},{0.0,0.0,-0.00148021886,0.0,0.00132754129,0.000750911272,},{0.0,0.0,0.0117148143,0.0,0.0020385092,0.0111247663,},{0.0,0.0,-0.0347062376,0.0,-0.0062631668,0.0070352025,},{0.0,0.0,-1.71276303e-06,0.0,-2.61542635e-05,-8.62814537e-05,},{0.0,0.0,-0.0001207205,0.0,-0.000157078511,4.39669436e-05,},{0.0,0.0,-0.00803694108,0.0,0.00630848604,0.0122857756,},{0.0,0.0,0.00137539531,0.0,0.000860872366,0.00151640324,},{0.0,0.0,0.0168670048,0.0,0.00729057417,0.00588229042,},{0.0,0.0,-0.000511724315,0.0,0.00207226658,0.000827838775,},{0.0,0.0,-0.00285877192,0.0,-0.000384615984,-0.000316215871,},{0.0,0.0,0.00538678827,0.0,-0.0029367638,0.00292475064,},{0.0,0.0,-0.000545346304,0.0,-0.000305703867,0.00134106612,},{0.0,0.0,0,0.0,0,0,},{0.0,0.0,-0.000270000994,0.0,0.000265674855,0.000231204042,},{0.0,0.0,0,0.0,0,0,},{0.0,0.0,-0.000646983336,0.0,0.000783653423,0.000237525521,}};
};


// MSMS section
TEST_F(ReadUtilUTest, checkMSMSExceptions)
{
  string path = test_dir_loc + "none.face";
  try
  {
    MSMSFile MSMStest(path);
    FAIL();
  }
  catch( const CouldNotReadException& err )
  {
    // check exception
    string error_exp = "Could not read: " + path;
    EXPECT_EQ(string(err.what()), error_exp);
  }
}

TEST_F(ReadUtilUTest, readMSMS)
{
  string path = test_dir_loc + "test.vert";
  MSMSFile MSMStest(path);
  vector<Pt> my_sp = MSMStest.get_sp();
  vector<Pt> my_np = MSMStest.get_np();

  ASSERT_EQ( my_sp.size(), 1669);
  ASSERT_EQ( my_np.size(), 1669);

  int ct = 0;
  for (int i=0; i<sp_x.size(); i += 100)
  {
    EXPECT_NEAR( my_sp[i].x(), sp_x[ct], preclim);
    EXPECT_NEAR( my_sp[i].z(), sp_z[ct], preclim);
    EXPECT_NEAR( my_np[i].y(), np_y[ct], preclim);
    EXPECT_NEAR( my_np[i].z(), np_z[ct], preclim);
    ct++;
  }

}

// Contact section
TEST_F(ReadUtilUTest, checkContactExceptions)
{
  string path = test_dir_loc + "none.cont";
  try
  {
    ContactFile contTest(path);
    FAIL();
  }
  catch( const CouldNotReadException& err )
  {
    // check exception
    string error_exp = "Could not read: " + path;
    EXPECT_EQ(string(err.what()), error_exp);
  }
}

TEST_F(ReadUtilUTest, readContact)
{
  string path = test_dir_loc + "test.cont";
  ContactFile contTest(path);
  vector<vector<int > > my_pr = contTest.get_at_pairs();

  ASSERT_EQ( contTest.get_moltype1(), 0);
  ASSERT_EQ( contTest.get_moltype2(), 21);

  vector<int > pair1 = {22, 47, 17};
  vector<int > pair2 = {46, 108, 455};
  vector<double > dst = {3.0, 2.57, 9.57};

  for (int i=0; i<my_pr.size(); i++)
  {
    ASSERT_EQ( my_pr[i][0], pair1[i]);
    ASSERT_EQ( my_pr[i][1], pair2[i]);
    EXPECT_NEAR( contTest.get_dists()[i], dst[i], preclim);
  }

}


// TransRot section
TEST_F(ReadUtilUTest, checkTransRotExceptions)
{
  string path = test_dir_loc + "none.transrot";
  try
  {
    PQRFile TRtest(path, 10);
    FAIL();
  }
  catch( const CouldNotReadException& err )
  {
    // check exception
    string error_exp = "Could not read: " + path;
    EXPECT_EQ(string(err.what()), error_exp);
  }
}

TEST_F(ReadUtilUTest, readTransRot)
{
  int M = 3;
  string trrot = test_dir_loc + "test.transrot";
  TransRotFile TRtest(trrot, M);
  vector<double> trx  = { 0.0, 53.20500, -53.20500};
  vector<double> tryy = { 0.0, 92.15376, 92.15376};
  vector<double> trz  = { 0.0, 0.0, 0.0};
  vector<vector<vector<double > > > rot = {
      {{1, 0, 0},              {0, 1, 0},              {0, 0, 1}},
      {{-0.5, -0.866025, 0.0}, { 0.866025, -0.5, 0.0}, {0, 0, 1}},
      {{-0.5,  0.866025, 0.0}, {-0.866025, -0.5, 0.0}, {0, 0, 1}} };
  
  ASSERT_EQ( trrot, TRtest.get_path());
  
  for (int i = 0; i < M; i++)
  {
    EXPECT_NEAR(TRtest.get_trans(i).x(), trx[i], preclim);
    EXPECT_NEAR(TRtest.get_trans(i).y(), tryy[i], preclim);
    EXPECT_NEAR(TRtest.get_trans(i).z(), trz[i], preclim);
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        MyMatrix<double> tmp = TRtest.get_rotmat(i);
        EXPECT_NEAR(tmp(j, k), rot[i][j][k], preclim);
      }
    }
  }
}

// PQR section
TEST_F(ReadUtilUTest, checkPQRExceptions)
{
  string path = test_dir_loc + "none.pqr";
  try
  {
    PQRFile PQRtest(path, 10);
    FAIL();
  }
  catch( const CouldNotReadException& err )
  {
    // check exception
    string error_exp = "Could not read: " + path;
    EXPECT_EQ(string(err.what()), error_exp);
  }
}

TEST_F(ReadUtilUTest, readPQR)
{
  string PQR = test_dir_loc + "2charge.pqr";
  PQRFile PQRtest(PQR, 10);
  vector<Pt> my_atoms = PQRtest.get_atom_pts();
  vector<Pt> my_cents = PQRtest.get_cg_centers();
  
  ASSERT_EQ( 1.85, PQRtest.get_cg_radii()[0]);
  ASSERT_EQ( PQR, PQRtest.get_path());
  ASSERT_EQ( my_atoms[0].x(), 0);
  ASSERT_EQ( my_atoms[0].y(), 0);
  ASSERT_EQ( my_atoms[0].z(), 0);
  
  ASSERT_EQ( my_atoms[1].x(), 0);
  ASSERT_EQ( my_atoms[1].y(), 1);
  ASSERT_EQ( my_atoms[1].z(), 0);
  
  ASSERT_EQ(   -1, PQRtest.get_charges()[0]);
  ASSERT_EQ( 1.67, PQRtest.get_charges()[1]);
  ASSERT_EQ( 0.45, PQRtest.get_radii()[0]);
  ASSERT_EQ( 0.20, PQRtest.get_radii()[1]);
  
  ASSERT_EQ(    1, PQRtest.get_cg_centers().size());
  ASSERT_EQ(    0, my_cents[0].x());
  ASSERT_EQ(    0, my_cents[0].y());
  ASSERT_EQ(    0, my_cents[0].z());
  ASSERT_EQ( 1.85, PQRtest.get_cg_radii()[0]);
}

TEST_F(ReadUtilUTest, readPQRNoCen)
{
  string PQR = test_dir_loc + "2charge_nocen.pqr";
  PQRFile PQRtest(PQR, 10);
  vector<Pt> my_atoms = PQRtest.get_atom_pts();
  
  ASSERT_EQ(   4, PQRtest.get_Nc()); 
  ASSERT_EQ( PQR, PQRtest.get_path());
  ASSERT_EQ( my_atoms[0].x(), 0);
  ASSERT_EQ( my_atoms[0].y(), 0);
  ASSERT_EQ( my_atoms[0].z(), 0);
  
  ASSERT_EQ( my_atoms[2].x(), 5);
  ASSERT_EQ( my_atoms[2].y(), 0);
  ASSERT_EQ( my_atoms[2].z(), 0);
  
  ASSERT_EQ(   -1, PQRtest.get_charges()[0]);
  ASSERT_EQ( 7.56, PQRtest.get_charges()[1]);
  ASSERT_EQ( 0.50, PQRtest.get_radii()[0]);
  ASSERT_EQ( 0.87, PQRtest.get_radii()[1]);
}

TEST_F(ReadUtilUTest, readPQRCen)
{
  int ct = 0;
  string PQR = test_dir_loc + "test_1BRS_cg.pqr";
  PQRFile PQRtest(PQR, 2000);
    
  ASSERT_EQ(1403, PQRtest.get_Nc());
  ASSERT_EQ(  47, PQRtest.get_Ns());
  ASSERT_EQ( PQR, PQRtest.get_path());
  
  ct = 0;
  for (int i=0; i < PQRtest.get_Nc(); i+=100)
  {
    EXPECT_NEAR( at_x[ct], PQRtest.get_atom_pts()[i].x(), preclim);
    EXPECT_NEAR( at_y[ct], PQRtest.get_atom_pts()[i].y(), preclim);
    EXPECT_NEAR( at_z[ct], PQRtest.get_atom_pts()[i].z(), preclim);
    EXPECT_NEAR( at_c[ct], PQRtest.get_charges()[i], preclim);
    EXPECT_NEAR( at_r[ct], PQRtest.get_radii()[i], preclim);
    ct++;
  }
}


TEST_F(ReadUtilUTest, checkXYZExceptions)
{
  string path = test_dir_loc + "none.xyz";
  try
  {
    PQRFile XYZtest(path, 10);
    FAIL();
  }
  catch( const CouldNotReadException& err )
  {
    // check exception
    string error_exp = "Could not read: " + path;
    EXPECT_EQ(string(err.what()), error_exp);
  }
}

TEST_F(ReadUtilUTest, checkXYZExceptionShort)
{
  string xyz = test_dir_loc + "2charge_short.xyz";
  try
  {
    XYZFile XYZtest(xyz, 10);
    FAIL();
  }
  catch( const NotEnoughCoordsException& err )
  {
    // check exception
    string error_exp = "File has 5 lines, need 10";
    EXPECT_EQ(string(err.what()), error_exp);
  }
}


TEST_F(ReadUtilUTest, readXYZ)
{
  string xyz = test_dir_loc + "2charge.xyz";
  XYZFile XYZtest(xyz, 10);
  
  ASSERT_EQ(  10, XYZtest.get_nmols());
  ASSERT_EQ( xyz, XYZtest.get_path());
}

TEST_F(ReadUtilUTest, readIFile)
{
  int p(3), ct;
  
  for( int i = 0; i < 17; i++)
  {
    ct = 0;
    string start = test_dir_loc + "imat_test/imat.sp";
    IMatFile ifil(start+to_string(i) + ".out.bin", 3);
    
    ASSERT_EQ(  3, ifil.get_p());
    ASSERT_EQ( start+to_string(i) + ".out.bin", ifil.get_path());
    
    for (int n = 0; n < p*p*p*p; n++)
    {
      EXPECT_NEAR( imat[i][n], ifil.get_mat_h(n), 1e-6);
    }
  }
}

TEST_F(ReadUtilUTest, readHFFile)
{
  int p(3), ct;
  
  for( int i = 0; i < 17; i++)
  {
    ct = 0;
    string start = test_dir_loc + "spol_test/test_0.00_p3.0.";
    HFFile htest(start+to_string(i) + ".H.exp", 3);
    HFFile ftest(start+to_string(i) + ".F.exp", 3);
  
    ASSERT_EQ(  3, htest.get_p());
    EXPECT_NEAR(  scl[i], htest.get_kappa(), preclim);
    EXPECT_NEAR(  1000, htest.get_rcut(), preclim);
    ASSERT_EQ( start+to_string(i) + ".H.exp", htest.get_path());
    
    ASSERT_EQ(  3, ftest.get_p());
    EXPECT_NEAR(  scl[i], ftest.get_kappa(), preclim);
    EXPECT_NEAR(  1000, ftest.get_rcut(), preclim);
    ASSERT_EQ( start+to_string(i) + ".F.exp", ftest.get_path());
    
    for (int n = 0; n < p; n++)
    {
      for (int m = 0; m < n+1; m++)
      {
        EXPECT_NEAR( spolHre[i][ct], htest.get_mat_nm(n,m).real(), preclim);
        EXPECT_NEAR( spolHim[i][ct], htest.get_mat_nm(n,m).imag(), preclim);
        EXPECT_NEAR( spolFre[i][ct], ftest.get_mat_nm(n,m).real(), preclim);
        EXPECT_NEAR( spolFim[i][ct], ftest.get_mat_nm(n,m).imag(), preclim);
        ct++;
      }
    }
  }
}


#endif /* readutilUnitTest_h */
